<template>
    <div>
        <h3>登录</h3>
        <table>
            <tr>
                <td>用户名</td>
                <td>
                    <input type="text" v-model="data.yhm">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="text" v-model="data.mm">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="登录" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';

const data=ref({
    "id": 0,
  "yhm": "",
  "mm": "",
  "xb": "",
  "dz": "",
  "sj": 0,
  "dqsj": ""
})

const add=()=>{
    axios.get("https://localhost:7234/api/we/login",{params:data.value}).then(res=>{
            if(res.data==1){
                alert("登录成功");
                location.href="/xs"
            }
            if(res.data==-2){
                alert("用户名不存在");
           
            }
            if(res.data==-1){
                alert("密码错误");
               
            }
    })
}

</script>

<style scoped>

</style>